import request from '@/utils/request'

// 查询论坛列表
export function listTopic(query) {
  return request({
    url: '/circle/topic/manage/list',
    method: 'get',
    params: query
  })
}

// 查询论坛详情
export function getTopic(id) {
  return request({
    url: '/circle/topic/detail',
    method: 'get',
    params: { id: id }
  })
}

// 新增论坛
export function addTopic(data) {
  return request({
    url: '/circle/topic/save',
    method: 'post',
    data: data
  })
}

// 修改论坛
export function updateTopic(data) {
  return request({
    url: '/circle/topic/save',
    method: 'post',
    data: data
  })
}

// 删除论坛
export function delTopic(id) {
  return request({
    url: '/circle/topic/delete',
    method: 'post',
    data: {'id': id},
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 设置论坛置顶
export function topicSetTop(topicId, topFlag) {
  return request({
    url: '/circle/topic/' + topicId + '/top',
    method: 'post',
    data: {'topFlag': topFlag},
    headers: {
      'Content-Type': 'multipart/form-data' // Important: set correct content type
    }
  })
}

/**
 * 查询论坛评论列表
 * @param query
 * @returns {*}
 */
export function topicCommunicationList(query) {
  return request({
    url: '/circle/topic/communication/list',
    method: 'get',
    params: query,
  })
}

/**
 * 查询论坛点赞列表
 * @param query
 * @returns {*}
 */
export function topicGreatList(query) {
  return request({
    url: '/circle/topic/communication/list',
    method: 'get',
    params: query,
  })
}
